//
//  MenuViewController.m
//  CoolTennisBall
//
//  Created by 谢伟康 on 15/12/17.
//  Copyright © 2015年 CoolLang. All rights reserved.
//

#import "MenuViewController.h"
#import "MenuTableViewController.h"
#import "NSBundle+CurrentLanguage.h"

@interface MenuViewController () <UIGestureRecognizerDelegate,DidSelectMenuTableView>
@property (weak, nonatomic) IBOutlet UIView *containerView;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *menuWidthConstraint;

@end

@implementation MenuViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.containerView.layer.cornerRadius = 5;
    self.containerView.layer.masksToBounds = YES;
    
    self.menuWidthConstraint.constant = [NSBundle currentLanguageIsChinese] ? 140.0f : 180.0f;
}

#pragma mark - IBAction

- (IBAction)clickCoverView:(id)sender {
    [self dismissFromParentViewControllerWithAnimationType:DetailViewControllerAnimationTypeFade];
}

#pragma mark - Segue
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    if ([segue.identifier isEqualToString:@"menuTableView"]) {
        MenuTableViewController * menuTableVC = (MenuTableViewController *)segue.destinationViewController;
        menuTableVC.delegate = self;
    }
}

#pragma mark - UIGestureRecognizerDelegate

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch
{
    return touch.view == self.view;
}

#pragma mark - DidSelectMenuTableView
- (void)didSeleceMenu:(MenuTableViewController *)menuTableVC atIndex:(NSInteger)index
{
    [self dismissFromParentViewControllerWithAnimationType:DetailViewControllerAnimationTypeFade];
}

@end
